/**
 * Created by oneminute on 7/17/14.
 */

var lz = require("../lib/utils/modules")();

exports.post = function (_req, _res, _opts, _callback) {
    var password = lz.Utils.decrypt(_opts.password);
    var loginPhone = lz.Utils.decrypt(_opts.loginPhone);
    var user = new lz.User({
        loginPhone: loginPhone,
        password: password
    });
    user.login(function (_err, _user) {
        lz.Logger.info("用户登陆是否成功: ", _err == null);
        if (_err == null && _user) {
            _req.query.uid = _user.id;
            _callback(_err, _user, _user.getInfo());
        } else {
            _callback(_err, null, null);
        }
    });
};
